package com.ksd.pug.controller.uservideo;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ksd.pug.commons.enums.ResultStatusEnumA;
import com.ksd.pug.commons.ex.PugValidationException;
import com.ksd.pug.commons.utils.fn.asserts.Vsserts;
import com.ksd.pug.controller.BaseController;
import com.ksd.pug.pojo.UserVideo;
import com.ksd.pug.service.uservideo.IUserVideoService;
import com.ksd.pug.vo.UserVideoVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * UserVideoController
 * 创建人:yykk<br/>
 * 时间：2022-05-17 14:04:38 <br/>
 * 源码下载：前台代码 git clone https://gitee.com/kekesam/kuangstudy-pug-ui.git
 * 飞哥B站地址：后台代码 git clone https://gitee.com/kekesam/kuangstudy-pug-parent.git
 * @version 1.0.0<br/>
 *
*/

@RestController
@RequiredArgsConstructor
@Slf4j
public class UserVideoController extends BaseController{

    private final IUserVideoService uservideoService;


    /**
     * 查询视频模块列表信息
     * @path : /admin/uservideo/load
     * @method: findUserVideos
     * @result : List<UserVideo>
     * 创建人:yykk
     * 创建时间：2022-05-17 14:04:38
     * @version 1.0.0
     * @return
     */
    @GetMapping("/uservideo/load")
    public List<UserVideo> findUserVideoList() {
        return uservideoService.findUserVideoList();
    }

	/**
	 * 查询视频模块列表信息并分页
	 * @path : /admin/uservideo/list
     * @method: findUserVideos
     * @param : uservideoVo
     * @result : IPage<UserVideo>
	 * 创建人:yykk
	 * 创建时间：2022-05-17 14:04:38
	 * @version 1.0.0
	*/
    @PostMapping("/uservideo/list")
    public IPage<UserVideo> findUserVideos(@RequestBody UserVideoVo uservideoVo) {
        return uservideoService.findUserVideoPage(uservideoVo);
    }


    /**
     * 根据视频模块id查询明细信息
     * @method: get/{id}
     * @path : /admin/uservideo/get/{id}
     * @param : id
     * @result : UserVideo
     * 创建人:yykk
     * 创建时间：2022-05-17 14:04:38
     * @version 1.0.0
    */
    @GetMapping("/uservideo/get/{id}")
    public UserVideo getUserVideoById(@PathVariable("id") String id) {
        if(Vsserts.isEmpty(id)){
           throw new PugValidationException(ResultStatusEnumA.ID_NOT_EMPTY);
        }
        return uservideoService.getUserVideoById(new Long(id));
    }


	/**
	 * 保存和修改视频模块
     * @method: saveupdate
	 * @path : /admin/uservideo/save
     * @param : uservideo
     * @result : UserVideo
	 * 创建人:yykk
	 * 创建时间：2022-05-17 14:04:38
	 * @version 1.0.0
	*/
    @PostMapping("/uservideo/saveupdate")
    public UserVideo saveupdateUserVideo(@RequestBody UserVideo uservideo) {
        return uservideoService.saveupdateUserVideo(uservideo);
    }


    /**
	 * 根据视频模块id删除视频模块
     * @method: delete/{id}
     * @path : /admin/uservideo/delete/{id}
     * @param : id
     * @result : int
	 * 创建人:yykk
	 * 创建时间：2022-05-17 14:04:38
	 * @version 1.0.0
	*/
    @PostMapping("/uservideo/delete/{id}")
    public int deleteUserVideoById(@PathVariable("id") String id) {
        if(Vsserts.isEmpty(id)){
            throw new PugValidationException(ResultStatusEnumA.ID_NOT_EMPTY);
        }
        return uservideoService.deleteUserVideoById(new Long(id));
    }


   /**
   	 * 根据视频模块ids批量删除视频模块
     * @method: uservideo/delBatch
     * @path : /admin/uservideo/delBatch
     * @param : uservideoVo
     * @result : boolean
   	 * 创建人:yykk
   	 * 创建时间：2022-05-17 14:04:38
   	 * @version 1.0.0
   	*/
    @PostMapping("/uservideo/delBatch")
    public boolean delUserVideo(@RequestBody UserVideoVo uservideoVo) {
        log.info("你要批量删除的IDS是:{}", uservideoVo.getBatchIds());
        if (Vsserts.isEmpty(uservideoVo.getBatchIds())) {
            throw new PugValidationException(ResultStatusEnumA.ID_NOT_EMPTY);
        }
        return uservideoService.delBatchUserVideo(uservideoVo.getBatchIds());
    }

}